/**
 * Created by Baggio on 2018-8-2.
 */
$(function () {

    $("#query").click(function () {
        var phone=$("#phone").val();
        var postData= {phone: phone};
        $.ajax({
            url: "/distributor/getDistributionRequirements.html",
            type: "post",
            dataType: "json",
            data:postData,
            beforeSend:function () {

                $(".loading").show();
                //执行ajax前执行loading函数.直到success
            },
            success: function (res) {
                $(".loading").hide();
                console.log(res);
                if (res.code != 1) {
                    alert(res.msg);
                    return;
                }
                $("#tbody").html("");
                showData(res.data.distributorList);

                showData(res.data.distributorSuperiorList);
            }
        });
    });

})
function showData(data) {
    console.log(data);
    if(data==undefined || data==null){
        return;
    }
    var html="";
    for(var i=0;i<data.length;i++){
        html+="<tr>";
        html+="<td>";
        html+=data[i].name;
        html+="</td>" ;
        html+="<td>";
        html+=data[i].phone;
        html+="</td>";
        html+="<td>";
        html+=data[i].amount;
        html+="</td>";
        html+="</tr>";
    }
    $("#tbody").append(html);
}